package br.com.californiahotel.client.viewControler;

import br.com.californiahotel.client.CaliforniaHotel;
import br.com.californiahotel.client.CaliforniaHotel.History;
import br.com.californiahotel.client.architecture.viewController.BasicController;

import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;


public class MainController extends BasicController {

	public interface Display extends DisplayController {
		ImgButton getAptoButton();
		ImgButton getServicesButton();
		ImgButton getBaggageButton();
		ImgButton getLogoutButton();
		ImgButton getReservaButton();
		ImgButton getLocationButton();
	}

	public MainController(Display display) {
		super(display);
	}

	@Override
	protected void bind() {
		getDisplay().getAptoButton().addClickHandler(menuButtonClickEvent(History.APARTAMENTOS));
		getDisplay().getServicesButton().addClickHandler(menuButtonClickEvent(History.SERVICOS));
		getDisplay().getBaggageButton().addClickHandler(menuButtonClickEvent(History.HOSPEDES));
		getDisplay().getReservaButton().addClickHandler(menuButtonClickEvent(History.RESERVAR_APTO));
		getDisplay().getLocationButton().addClickHandler(menuButtonClickEvent(History.ALUGAR_APTO));
		getDisplay().getLogoutButton().addClickHandler(menuButtonClickEvent(History.LOGIN));
	}

	private ClickHandler menuButtonClickEvent(final History button) {
		return new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				CaliforniaHotel.changeHistory(button);
			}
		};
	}

	private Display getDisplay() {
		return ((Display)getDisplayController());
	}

}
